home *** CD-ROM | disk | FTP | other *** search
- Path: jupiter.planet.net!usenet
- From: cygnusx@planet.net (David)
- Newsgroups: comp.lang.c
- Subject: Help-Assignment2// This time I am posting the code!!!Thanx
- Date: Sat, 24 Feb 1996 03:58:34 GMT
- Organization: Planet Access Networks - Stanhope, NJ
- Message-ID: <312e8912.8777775@news.planet.net>
- NNTP-Posting-Host: newt19.planet.net
- X-Newsreader: Forte Agent .99d/32.182
-
-
- I got flamed pretty good for asking for help without posting any code
- on my last assignment so have included what I wrote on this one.
- anyway thanx to all of you who were kind enough to give me suggestions
- as I finished it and am on to a more challenging program ? well
- challenging for a green horn like me anyway !!!.
-
- I wrote this program that prompts the user to input an amount of
- values the user will enter . It then prompts for the specifed values
- and stores them . Then it calculates the High, low and average of the
- inputed values in the array and prints them out. The problem is I
- would like to make these 3 calculations as Function Prototypes at the
- beginning of the program and have them called on but am having
- trouble passing the array to them ???.
-
- The program below runs and does the specifed tasks but is not in
- function prototype form. Any Idea's on passing the array values to
- these functions????
-
- Thanx much, David
-
- #include<stdio.h>
-
- main()
- {
-
- float A[100];
- float amount,total,value,max,ctr,min,avg;
-
-
- printf(" This Program accepts values from the user up to\n"
- " a maximum 100 and calculates the high, low and \n"
- " average of the total values entered.\n");
-
- printf("\nPlease enter the amount of values you wish to use ?\n\n");
- scanf("%f",&amount);
-
- for ( total =0;total<=amount-1;total++)
-
- { printf(" \nPlease enter a number : ");
- scanf("%f",&A[total]);}
-
-
- printf(" \n\nThe values you have entered are as follows\n\n");
-
- for (value =0;value<=amount-1;value++)
-
- printf("%6.1f",A[value]);
-
-
- max=A[0]; /* max value calculation*/
-
- for (ctr=1;ctr<amount;ctr++)
-
- if (A[ctr]>max)
- {max=A[ctr];}
-
- printf("\n\nThe Max Value of all entered is: %5.1f\n",max);
-
-
-
- min=A[0]; /* min value calculation*/
-
- for (ctr=1;ctr<amount;ctr++)
-
- if (A[ctr]<min)
- {min=A[ctr];}
-
- printf("\n\nThe Min Value of all entered is: %5.1f\n",min);
-
-
-
- avg=A[0]; /* average value calculation*/
-
- for (ctr=1;ctr<amount;ctr++)
-
- avg += A[ctr];
-
- printf("\n\nThe Avg Value of all entered is: %6.2f\n",avg/amount);
-
- return 0; }
-
-
-
-
-
-
-